     <div class='row'> 
      <div class='span6'>
        <div class='panel'>
        <h2 style="margin-bottom:20px;">Team: <?php echo $user_info->username;?></h2>

      <?php if(!tour_started() && $user->id == $user_info->id) { ?>
      <div class='buttons' style="margin-bottom: 20px;"><?php echo anchor('selection/edit', '<i class="icon-edit icon-white"></i> '.lang('edit_selection'), 'class="btn btn-primary"'); ?></div>
      <p><?php echo lang('selection_intro_pre'); ?></p>
      <?php
      }
      ?>
        <p><?php echo sprintf(lang('overall_score_for_team'), $user_info->username);?>:</p>
        <table class='table table-condensed'>
          <thead>
            <tr>
              <th><?php echo lang('rider');?></th>
              <th class='centertext'><a href="#" rel="tooltip" title="<?php echo lang('stage_results');?>"><img src="<?php echo base_url();?>assets/images/jersey_stage.gif" /></a></th>
              <th class='centertext'><a href="#" rel="tooltip" title="<?php echo lang('overall_standing');?>"><img src="<?php echo base_url();?>assets/images/jersey_yellow.gif" /></a></th>
              <th class='centertext'><a href="#" rel="tooltip" title="<?php echo lang('points_standing');?>"><img src="<?php echo base_url();?>assets/images/jersey_green.gif" /></a></th>
              <th class='centertext'><a href="#" rel="tooltip" title="<?php echo lang('mountain_standing');?>"><img src="<?php echo base_url();?>assets/images/jersey_mountain.gif" /></a></th>
              <th class='centertext'><?php echo lang('total');?></th>
            </tr>
          </thead>
          <tbody>

        <?php $total_points = 0;?>
        <?php
        if(isset($riders))
        {
          foreach($riders as $rider)
          {
          ?>
            
          <?php    
            if (isset($rider) && is_object($rider))
            {
              $class="rider";
              if (!$rider->active)
              {
                $class .= " inactive";
              }
          ?>   
                <tr class="<?php echo $class;?>">
                  <td><?php echo $rider->number." ".
                  anchor('info/rider/'.$rider->rider_id,$rider->last_name." ".$rider->first_name)." (".anchor('info/team/'.$rider->team_number, $rider->team_shortname).")"; ?></td>
                  <td class='centertext'>
                    <?php
                    if(array_sum(explode(',',$rider->points_stage)) > 0 )
                    {
                      echo array_sum(explode(',',$rider->points_stage));
                    }
                    else
                    {
                      echo "-";
                    }?>
                  </td>
                  <td class='centertext'>
                   <?php
                    if(array_sum(explode(',',$rider->points_stage_yellow)) > 0 )
                    {
                      echo array_sum(explode(',',$rider->points_stage_yellow));
                    }
                    else
                    {
                      echo "-";
                    }?>
                  </td>
                  <td class='centertext'>
                   <?php
                    if(array_sum(explode(',',$rider->points_stage_green)) > 0 )
                    {
                      echo array_sum(explode(',',$rider->points_stage_green));
                    }
                    else
                    {
                      echo "-";
                    }?>
                  </td>                
                  <td class='centertext'>
                   <?php
                    if(array_sum(explode(',',$rider->points_stage_mountain)) > 0 )
                    {
                      echo array_sum(explode(',',$rider->points_stage_mountain));
                    }
                    else
                    {
                      echo "-";
                    }?>
                  </td>
                  <td class='centertext'>
                    <?php
                    if (array_sum(explode(',',$rider->points_stage)) + array_sum(explode(',',$rider->points_stage_yellow)) + array_sum(explode(',',$rider->points_stage_green)) + array_sum(explode(',',$rider->points_stage_mountain))>0)
                    {
                      echo array_sum(explode(',',$rider->points_stage)) + array_sum(explode(',',$rider->points_stage_yellow)) + array_sum(explode(',',$rider->points_stage_green)) + array_sum(explode(',',$rider->points_stage_mountain));
                    }
                    else
                    {
                      echo "-";
                    }                    
                    $total_points = $total_points + array_sum(explode(',',$rider->points_stage)) + array_sum(explode(',',$rider->points_stage_yellow)) + array_sum(explode(',',$rider->points_stage_green)) + array_sum(explode(',',$rider->points_stage_mountain));?>
                  </td>                  
                </tr>
           <?php
            }
          }
        } ?>
         </tbody>
           <tfoot>
            <tr>
                <td colspan='5' class='righttext'><?php echo lang('total').": ";?></td>
                <td class='centered'><?php echo $total_points;?></td>
            </tr>
          </tfoot>
        </table>
      </div>
    </div>

    <div class='span6'>
    <div class='panel'>
      <h2><?php echo lang('score_by_stage'); ?></h2>
      <p><?php echo sprintf(lang('points_per_stage_for_team'), $user_info->username);?>:</p>
      <table class='table table-condensed'>
        <thead>
          <tr>
            <th></th>
            <th class='centertext'><a href="#" rel="tooltip" title="<?php echo lang('stage_results');?>"><img src="<?php echo base_url();?>assets/images/jersey_stage.gif" /></a></th>
            <th class='centertext'><a href="#" rel="tooltip" title="<?php echo lang('overall_standing');?>"><img src="<?php echo base_url();?>assets/images/jersey_yellow.gif" /></a></th>
            <th class='centertext'><a href="#" rel="tooltip" title="<?php echo lang('points_standing');?>"><img src="<?php echo base_url();?>assets/images/jersey_green.gif" /></a></th>
            <th class='centertext'><a href="#" rel="tooltip" title="<?php echo lang('mountain_standing');?>"><img src="<?php echo base_url();?>assets/images/jersey_mountain.gif" /></a></th>
            <th class='centertext'><?php echo lang('total');?></th>
          </tr>
        </thead>
        <tbody>
    <?php
    foreach($points as $p)
    {
    ?>
          <tr>
            <td><?php echo lang('stage')." ".$p->points_stage_id;?></td>
            <td class='centertext'><?php echo $p->points_stage;?></td>
            <td class='centertext'><?php echo $p->points_yellow;?></td>
            <td class='centertext'><?php echo $p->points_green;?></td>
            <td class='centertext'><?php echo $p->points_mountain;?></td>
            <td class='centertext'><?php echo $p->points_total;?></td>
          </tr>
    <?php
    }
    ?> 
        </tbody>
      </table>
    </div>
    </div>
        
  </div>
